<?php
require_once FRAMEWORK_PATH . 'View' . DIRECTORY_SEPARATOR . 'TemplateEngine' . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . 'Smarty.class.php';

class View_Smarty implements View_Interface {
    
    /**
     * @var Smarty
     */
    private $_templateEngine;
    
    public function __construct () {
        $this->_templateEngine = new Smarty();
        
        $config = Config::get('template', 'config');
        $this->_templateEngine->template_dir = APP_PATH . "view";
        $this->_templateEngine->compile_dir = APP_PATH . "view/template_c/file_smarty";
        //$this->_templateEngine->config_dir = APP_PATH . "view/configs";
        $this->_templateEngine->cache_dir = ROOT_PATH . "cache/smarty";
        $this->_templateEngine->caching = false;
        $this->_templateEngine->compile_check = $config['compile_check'];
        
        $this->_templateEngine->assign_by_ref('View_Helper', new View_Helper());
    }
    
    public function assign (array $data) {
        $this->_templateEngine->assign($data);
    }
    
    public function display ($tpl) {
        $tpl .= '.tpl';
        $this->_templateEngine->display($tpl);
    }

}
?>